package com.neutech.maplestory.client;

import com.neutech.maplestory.entity.Arrow;
import com.neutech.maplestory.entity.Direction;
import com.neutech.maplestory.entity.Hero;
import com.neutech.maplestory.util.MapleStoryFrame;

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.ArrayList;

/** 游戏的主入口文件
 * @author 小李要吃鱼
 * @date 2021-01-27 10:16
 */
public class MapleStoryClient extends MapleStoryFrame {
    public Hero hero = new Hero(this,300,500);
    public List<Arrow> arrows = new ArrayList<>();
//    public Arrow arrow = new Arrow(400,500, Direction.RIGHT);

    @Override
    public void init() {
        super.init();
        /*添加键盘监听器*/
        this.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent e) {
                hero.keyPressed(e);
            }

            @Override
            public void keyReleased(KeyEvent e) {
                hero.keyPressed(e);
            }
        });
    }
            @Override
            public void paint(Graphics g) {
                hero.draw(g);
//                arrow.draw(g);
                for( int i = 0; i < arrows.size();i++){
                    arrows.get(i).draw(g);
                }
                Font f = g.getFont();
                g.setFont(new Font("微软雅黑", Font.BOLD, 30));
                g.drawString("当前人物的方向为" + hero.dir, 100, 100);
                g.drawString("当前人物的方动作为" + hero.action, 100, 150);
                g.drawString("shoot" + hero.shoot, 100, 200);
                g.drawString("arrows.size()" + arrows.size(), 100, 250);
                g.setFont(f);
            }

            public static void main(String[] args) {
                new MapleStoryClient().init();
            }
        }

